]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/viewport: Fix horizontal translation in RTL locales
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 16 Jun 2020 20:53:37 +0000 (22:53 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 16 Jun 2020 21:57:51 +0000 (23:57 +0200)
In RTL locales, the lowest value should correspond to the right-most
position and vice-versa.

That this went unnoticed for so long shows how we have avoided horizontal
scrolling so far :-)

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1318

src/st/st-viewport.c

index 0eb5a22a1ebb93f3927d26da6b97ba991ca6963c..fb1df91d905efe3268e0ce5f3025212ef8c20636 100644 (file)
@@ -301,6 +301,26 @@ st_viewport_allocate (ClutterActor           *actor,
     }
 }
 
+static double
+get_hadjustment_value (StViewport *viewport)
+{
+  StViewportPrivate *priv = st_viewport_get_instance_private (viewport);
+  ClutterTextDirection direction;
+  double x, upper, page_size;
+
+  if (!priv->hadjustment)
+    return 0;
+
+  st_adjustment_get_values (priv->hadjustment,
+                            &x, NULL, &upper, NULL, NULL, &page_size);
+
+  direction = clutter_actor_get_text_direction (CLUTTER_ACTOR (viewport));
+  if (direction == CLUTTER_TEXT_DIRECTION_RTL)
+    return upper - page_size - x;
+
+  return x;
+}
+
 static void
 st_viewport_apply_transform (ClutterActor *actor,
                              CoglMatrix   *matrix)
@@ -314,7 +334,7 @@ st_viewport_apply_transform (ClutterActor *actor,
   parent_class->apply_transform (actor, matrix);
 
   if (priv->hadjustment)
-    x = st_adjustment_get_value (priv->hadjustment);
+    x = get_hadjustment_value (viewport);
   else
     x = 0;
 
@@ -336,7 +356,7 @@ get_border_paint_offsets (StViewport *viewport,
   StViewportPrivate *priv = st_viewport_get_instance_private (viewport);
 
   if (priv->hadjustment)
-    *x = st_adjustment_get_value (priv->hadjustment);
+    *x = get_hadjustment_value (viewport);
   else
     *x = 0;